package pers.fulsun.demo.springcloud.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pers.fulsun.demo.springcloud.controller.Client2FeignIntercept;
import pers.fulsun.demo.springcloud.entity.User;
import pers.fulsun.demo.springcloud.mapper.UserMapper;
import pers.fulsun.demo.springcloud.service.UserService;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author fulsun
 * @since 2021-08-18
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    //内部调用接口的feignclient
    @Autowired
    private Client2FeignIntercept client2FeignIntercept;
    @Transactional //本地事务注解
    @LcnTransaction //分布式事务注解
    public void addUser(User user) {
        this.baseMapper.insert(user);
        //调用内部接口更新client_total
        this.client2FeignIntercept.addUser(user.getName());
    }

}
